import Vue from 'vue';
import Components from './func-notification';

const NotificationConstructor = Vue.extend(Components); 

const instances = [];
let seed = 1;

const notify = (options) => {
	if(Vue.prototype.$isServer){
		return;
	}
	const instance = new NotificationConstructor({
		propsData: options
	});
	const id = `notification_${seed++}`;
	instance.id = id;
	instance.vm = instance.$mount();
	console.log(instance)
	document.body.appendChild(instance.vm.$el);
	
	let verticalOffset = 0;
	instances.forEach(item => {
		verticalOffset += item.$el.offsetHeight +16
	});
	verticalOffset += 16;
	instance.verticalOffset = verticalOffset;
	instances.push(instance);
	return instance.vm;
}
 export default notify;



